import os
from openai import OpenAI

# 假设您已经将DEEPSEEK_API_KEY设置为环境变量
api_key = os.getenv("DEEPSEEK_API_KEY")

if api_key is None:
    raise ValueError("请确保设置了环境变量 DEEPSEEK_API_KEY.")

client = OpenAI(
    api_key=api_key,  # 使用从环境变量中获取的实际API密钥
    base_url="https://api.deepseek.com"  # DeepSeek API的基础URL
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Hello"},
    ],
    stream=False
)

print(response.choices[0].message.content)